using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;

public class AudioSliderController : MonoBehaviour
{
    [SerializeField] private AudioMixer audioMixer;
    [SerializeField] private float multiplier;
    public Slider slider;
    public string parametr;
    public void SliderValue(float value) => audioMixer.SetFloat(parametr, Mathf.Log10(value) * multiplier);
    private void OnEnable()
    {
        slider.GetComponent<Slider>().onValueChanged.AddListener(SliderValue);
    }
    private void OnDisable()
    {
        slider.GetComponent<Slider>().onValueChanged.RemoveAllListeners();
    }
    public void LoadSlider(float value)
    {
        if(value>=0.001f)
            slider.value=value;
    }
}
